/******************************************************************************
 *Copyright (C) 2024 EternalChip, Inc.(Gmbn) or its affiiates.
 *
 * All Rignts Reserved
 * 
 * @file bsp_led_driver.h
 * 
 * @par dependencies
 * -stdio.h
 * -stdint.h
 * 
 * @author ssm |R&D Dept. |EternalChip 立芯嵌入式
 * 
 * biref Provide the APIs of LEDS and corresponding operations,
 * 
 * Processing flow;
 * 
 * call directly.
 * 
 * @version V1.0 2025-6-5
 * 
 * @note 1 tab == 4 spaces!
 * 
******************************************************************************/

#ifndef __BSP_LED_DRIVER_H__
#define __BSP_LED_DRIVER_H__

//******************************  Icludes ************************************//

#include <stdio.h>
#include <stdint.h>

//******************************  Icludes ************************************//

//******************************  Defines ************************************//


#define INITED   1                  /*LED is init                             */
#define NOT_INIT 0                  /*LED is not init                         */

#define OS_SUPPIRTING               /*OS sUPPRTING depend on OS avalible      */
#define DEBUG                       /*ENABLE DEBBUG                           */
#define DEBUG_OUT(X)    printf(X)   /*DEBBUG oueput info indicate statues     */ 

typedef enum{
    LED_OK            =0,           /* LED Operation complete successfully    */
    LED_ERROR         =1,           /* LED Run-time error withoutcase matched */
    LED_ERRORTIMEROUT =2,           /* LED Operation falied with timeout      */
    LED_ERRORRESOURCE= 3,           /* LED Reasource not available            */
    LED_ERRORPARAMETER=4,           /* LED Parameter error                    */
    LED_ERRORNOMEMORY =5,           /* LED Out of memory                      */
    LED_ERRORISR      =6,           /* LED Not allowed in ISR context         */
    LED_RESERVED      =7,           /* LED Reserved                           */
} led_status_t;

typedef enum{
    PROPORTION_1_3    =0,   
    PROPORTION_1_2    =1,
    PROPORTION_1_1    =2,
    PROPORTION_x_x    =0XFF,
} proportion_t;

typedef struct  
{
    led_status_t (*pf_led_on)(void);
    led_status_t (*pf_led_off)(void);
} led_operations_t;

typedef struct  
{
    led_status_t (*pf_get_time_ms)(uint32_t * const);
} time_base_ms_t;
#ifdef OS_SUPPIRTING
typedef struct  
{
    led_status_t (*pf_os_delay_ms)(const uint32_t *);
} os_delay_ms_t;

#endif //OS_SUPPIRTING
typedef led_status_t (*pf_led_control)(uint32_t    ,//Cycle_time[ms]
                                       uint32_t    ,//blink_times[times]
                                       proportion_t //proportion_on_off
                                                    );

typedef struct {
    /*******Targent of Internal Statues***********/
    uint8_t                                is_init;

    /***********Targent of Featers****************/
		/* The whole time of blink                   */
    uint32_t                         cycle_time_ms;
		/* The time of blink                         */
	uint32_t                           blick_times;
		/* The relationship of light on and off time */
    proportion_t                 proportion_on_off;

    /***********Targent of IOS needed*************/
    /* The interface from Core                   */
    led_operations_t              *p_led_opes_inst;
    time_base_ms_t                 *p_time_base_ms;
    /* The interface from OS                     */
#ifdef OS_SUPPIRTING
    os_delay_ms_t                  *p_os_delay_ms;
#endif //OS_SUPPIRTING

    /***********Targent of APIS      *************/
    pf_led_control                  pf_led_control;
}bsp_led_driver_t;

//******************************  Defines ************************************//


//******************************  Declaring **********************************//



led_status_t led_driver_inst(
                                bsp_led_driver_t * 		self,
                                led_operations_t *    led_ops,
#ifdef OS_SUPPIRTING
                                os_delay_ms_t    *   os_delay,
#endif //OS_SUPPIRTING																
                                time_base_ms_t   *   timebase
);

//******************************  Declaring **********************************//

#endif
